import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';
import store from '@/store/public';
import { observe } from 'mobx';

export default function WorkerInit(){
	const location = useLocation();
  useEffect(() => {
  	// 监听路由操作，并传值给web worker
    const timer = setTimeout(()=>{
    	// postMessage({
    	// 	type:'router',
    	// 	action:'pageRouter',
    	// 	value:location.pathname
    	// })
    })
    return () => clearTimeout(timer)
  }, [location]);
  useEffect(()=>{
  	// 监听页面是否展示，并传值给web worker
  	let timer = setTimeout(()=>{
  		observe(store,'isPageTabShow',res => {
  			console.log(res.newValue)
  		})
  	})
  	return () => clearTimeout(timer)
  },[])
	return <></>
}